<template>
    <view class="mybox">
        <nav-bar></nav-bar>
        <view class="mymessage" @click="mydata">
            <view class="textSty">
                {{info.name || (info.nickname || '')}}
                <text class="phone" v-if="info.is_hs == 5">(分站回收员)</text>
                <text class="phone" v-else-if="info.is_hs == 3">(总仓回收员)</text>
                <text class="phone" v-else-if="info.is_hs == 1">(回收员)</text>
				<text class="phone" v-else-if="info.is_hs == 2">(分销员)</text>
				
            </view>
            <view class="phone">{{info.mobile || ""}}</view>
			<view style="padding-top: 20rpx" v-if="info.is_hs == 1">我的积分：{{userInfo.point || 0}}</view>
            <image class="userimg" :src="info.avatar || '../../../../static/img/navimg/Tab-icon-Active-04@3x.png'"
                   mode=""></image>
        </view>
        <view class="mymoney">
            <view class="mymoneyson" @click="mybalance">
                <p class="mymon">我的钱包</p>
                <p class="mymonn">￥<span class="text-style-1">{{info.balance}}</span></p>
                <button class="sebutton" @click="blank">查看详情</button>
                <i class=".sanj"></i> 
            </view>
        </view>
		<view class="gotoshop" @click="toshop" v-if="info.is_hs == 1">
		    <image class="img" src="https://re.gxqichang.cn/mini/myhome/my-shangcheng@3x.png" alt="error">
		    </image>
		    <view class="textbutton">
		        <text class="text">积分可兑换礼品</text>
				 <view class="point" style="margin-left: 48rpx;">￥{{userInfo.point || "0.00"}}</view>
		        <button class="button">进入积分商城</button>
		    </view>
		</view>
        <!-- <view class="mymoney" style="height: auto;" v-if="info.is_manage == 1"> -->
            <view class="service-box">
                <view @click ="toServiceStorage(1)">
                    <image class="box-img"  src="../../../../static/img/myhome/yuanliao.png"></image>
                    <view  class="tc">原料库</view>
                    
                </view>
                <view @click ="toServiceStorage(2)">
                    <image class="box-img" src="../../../../static/img/myhome/chengpin.png"></image>
                    <view class="tc">成品库</view>
                    
                </view>
                <view @click ="toServiceStorage(3)">
                    <image class="box-img" src="../../../../static/img/myhome/feipin.png"></image>
                    <view  class="tc">废品库</view>    
                </view>
            </view>
        <!-- </view> -->
        <view class="mysetting">
            <!-- <view class="order" @click="mydata">
                <image class="orderimg1" src="../../../../static/img/myhome/sc-my-icon-dizhi@3x.png"></image>
                <span>设置地址</span>
                <image class="orderimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>
            <hr /> -->
            <view class="Swap" @click="gettabindx(0)">
                <image class="Swapimg1" src="../../../../static/img/myhome/my-icon-huangou@3x.png"></image>
                <span>订单记录</span>
                <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>
            <view class="Swap" @click="toCommission">
                <image class="Swapimg1" src="../../../../static/img/myhome/my-icon-cyjl@3x.png"></image>
                <span>抽佣记录</span>
                <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>
            <!--<view class="Swap" @click="toStatistics" v-if="info.is_hs != 3">-->
            <view class="Swap" @click="toStatistics">
                <image class="Swapimg1" src="../../../../static/img/myhome/my-icon-ddtj@3x.png"></image>
                <span>回收统计</span>
                <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>
            <view class="Swap" @click="toStatistics" v-if="info.is_hs != 5">
                <image class="Swapimg1" src="../../../../static/img/myhome/my-icon-ddtj@3x.png"></image>
                <span>卖货统计</span>
                <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>
				<!-- mypages/Myhome/card -->
			<view class="Swap" @click="toCard" v-if="info.is_hs == 1">
			    <image class="Swapimg1" src="../../../../static/img/myhome/my-icon-zcxd@3x.png"></image>
			    <span>银行卡</span>
			    <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
			</view>
			
			<view class="order" @click="toExchange_record"  v-if="info.is_hs == 1">
			    <view class="order-disp">
			        <image class="orderimg1" src="../../../../static/img/myhome/my-icon-zcxd@3x.png"></image>
			        <span>换购记录</span>
			    </view>
			    <image class="orderimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
			</view>
			<view class="order" @click="toPoint_record"  v-if="info.is_hs == 1">
			    <view class="order-disp">
			        <image class="orderimg1" src="../../../../static/img/myhome/my-icon-zcxd@3x.png"></image>
			        <span>积分记录</span>
			    </view>
			    <image class="orderimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
			</view>
			
            <view class="Swap" @click="toEditOrder" v-if="info.is_hs == 3">
                <image class="Swapimg1" src="../../../../static/img/myhome/my-icon-zcxd@3x.png"></image>
                <span>总仓下单</span>
                <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>
            <view class="Swap" @click="toEditOrder" v-else-if="info.is_hs == 5">
                <image class="Swapimg1" src="../../../../static/img/myhome/my-icon-zcxd@3x.png"></image>
                <span>分站下单</span>
                <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>
            
            <!--<view class="Swap" @click="toSelectWeight" v-if="info.is_hs == 3 || info.is_hs == 5">
                <image class="Swapimg1" src="../../../../static/img/myhome/my-icon-zcxd@3x.png"></image>
                <span>选择地磅</span>
                <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>-->
            
            <view class="Swap" @click="toScanList" v-if="info.is_hs == 3 || info.is_hs == 5">
                <image class="Swapimg1" src="../../../../static/img/myhome/my-icon-zcxd@3x.png"></image>
                <span>扫码订单</span>
                <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>
            
            <view class="Swap" @click="toHangList" v-if="info.is_hs == 3 || info.is_hs == 5">
                <image class="Swapimg1" src="../../../../static/img/myhome/my-icon-zcxd@3x.png"></image>
                <span>挂起订单</span>
                <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>
            <view class="Swap" @click="toOrderList" v-if="info.is_hs == 3 || info.is_hs == 5">
                <image class="Swapimg1" src="../../../../static/img/myhome/my-icon-zcxd@3x.png"></image>
                <span>下单记录</span>
                <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>
				
            <view class="Swap" @click="toMyCarList" v-if="info.is_hs == 5">
                <image class="Swapimg1" src="../../../../static/img/myhome/che.png"></image>
                <span>车辆信息</span>
                <image class="Swapimg2" src="../../../../static/img/myhome/my-list-more@3x.png" mode=""></image>
            </view>
            
        </view>
        
        <view class="line-space"></view>
    </view>
</template>

<script>
    export default {
        props: {
            info: {
                type: Object
            }
        },
        data() {
            return {
                //设置地磅
                isSetWeight: 0,
                // info: {},
            }
        },
        mounted() {
            this.setWeight();
            // this._getInfo();
            this._getWp()
        },
        methods: {
            blank() {
                uni.navigateTo({
                    url: './myhome/balance'
                })
            },
            mydata() {
                uni.navigateTo({
                    url: './myhome/predata'
                })
            },
            mybalance() {
                uni.navigateTo({
                    url: './balance'
                })
            },
            
            gettabindx(index) {
                this.$parent.$refs.tabbar.clicktabbars(index)
                this.$emit('index', index)
            },
            toCommission() {
                uni.navigateTo({
                    url: './myhome/commission'
                })
            },
            toStatistics() {
                uni.navigateTo({
                    url: './myhome/statistics'
                })
            },
			toCard(){
				uni.navigateTo({
				    url: '/mypages/Myhome/card'
				})	
			},
			// 跳转至商城
			toshop() {
			    uni.redirectTo({
			        url: '/shop/pages/index/index'
			    })
			},
            toEditOrder() {
                // if (this.isSetWeight == 0) {
                //     uni.showToast({
                //         title: '地磅设置异常',
                //         duration: 1000,
                //         icon: 'none'
                //     });
                //     return false;
                // }
                
                uni.navigateTo({
                    url: '../Home/order/Edit_order?form_page=1'
                })
            },
            toHangList(){
                uni.navigateTo({
                    url: '../Home/order/hangList'
                })
            },
            toOrderList(){
                uni.navigateTo({
                    url: '../Home/order/orderList'
                })
            },
            toMyCarList(){
                uni.navigateTo({
                    url: './myhome/mycar_list'
                })
            },
			// 跳转换购记录
			toExchange_record() {
			    uni.navigateTo({
			        url: '/mypages/Myhome/Exchange_record'
			    })
			},
			// 跳转积分记录
			toPoint_record() {
			    uni.navigateTo({
			        url: '/mypages/Myhome/Point_record'
			    })
			},
            //20220907
            toScanList(){
                // if (this.isSetWeight == 0) {
                //     uni.showToast({
                //         title: '地磅设置异常',
                //         duration: 1000,
                //         icon: 'none'
                //     });
                //     return false;
                // }
                
                uni.navigateTo({
                    url: '../../../mend/scan_admin/hangList1'
                })
            },
            toSelectWeight(){
                uni.navigateTo({
                    url: '../../../mend/scan_admin/weightList'
                })
            },
            _getWp() {
                var serverId = this.$store.state.userInfo.service_id;
                if(serverId > 0){
                    this._getwptypelist(serverId)
                }
            },
            _getwptypelist(serverId) {
                this.$u.api.getwptypelist({
                    service_id: serverId
                }).then(res => {
                    res.forEach((item, index) => {
                        item.plist.forEach((it, idx) => {
                            return it.extra = it.u_price + ',' + it.unit
                        })
                    })
                    uni.setStorageSync('setWptypeList', res)
                })
            },
            // 用户信息api
            _getInfo() {
                this.$u.api.getInfo().then(res => {
                    this.info = res;
                    uni.setStorageSync('is_hs', res.is_hs);
                    this.$store.commit('setUserInfo', res)
                    uni.setStorageSync('userInfo', res);
                    this.$store.commit('setIsUserEdit', 0);
                    if(res.is_hs == 0 || res.is_hs == 2) {
                        uni.reLaunch({
                            url: '/mypages/User/index'
                        });
                        this.$store.commit('changeactive', 0)
                    }
                }).catch(e => {
                })
            },
            //20221121
            setWeight(){
                var serverId = this.$store.state.userInfo.service_id;
                if (!serverId) {
                    uni.showToast({
                        title: '请绑定服务站点',
                        duration: 1000,
                        icon: 'none'
                    });
                    return false;
                }

                this.$u.api.getServiceInit().then(res => {
                    uni.setStorageSync('service_init',res)
                    if(res.service_setting){
                        if(res.service_setting.MQTT_NUMBER  >0){
                            this.isSetWeight = 1;
                        }
                    }
                })
            
                // var params = {};
                // this.$u.api.getServer2weight(params).then(res => {
                //     var serList = res;
                //     var ipos = -1;
                //     for (var i = 0; i < serList.length; i++) {
                //         if (serList[i].server_id == serverId) {
                //             ipos = i;
                //             break;
                //         }
                //     }
                //     if (ipos != -1) {
                //         this.$store.state.MQTT_NUMBER = serList[ipos].num;
                //         this.isSetWeight = 1;
                //     }
                // }).catch(err => {
                // });
            },
            toServiceStorage(type){
                let url = ['','crude','finish','waste']
                
                let navigateTo = url[type]
                
                uni.navigateTo({
                    url: '/homepage/Test/Home/myhome/service/'+navigateTo
                })
            }
        },
        onPullDownRefresh() {
            uni.stopPullDownRefresh()
        }
    }
</script>

<style lang="scss" scoped>
    .service-box{
        display: flex;justify-items: center;justify-content: space-around;margin: 20rpx;
    }
    .box-img{
        width: 100rpx;height: 100rpx;
    }
    .tc{
        text-align: center
    }
    .mybox {
        background-color: #FFFFFF;
        min-height: 100vh;
    }

    .mymessage {
        position: relative;
        width: 611rpx;
        height: 144rpx;
        margin: 30rpx 70rpx;

        .textSty {
            height: 48rpx;
            font-family: PingFang-SC-Heavy;
            font-size: 50rpx;
            font-weight: 600;
            line-height: 38rpx;
            color: #191919;
        }

        .phone {
            width: 200rpx;
            height: 22rpx;
            font-family: PingFang-SC-Bold;
            font-size: 28rpx;
            font-weight: normal;
            font-stretch: normal;
            line-height: 48rpx;
            letter-spacing: 0rpx;
            color: #999999;
            margin-top: 30rpx;
        }

        .userimg {
            position: absolute;
            top: 0;
            right: 0;
            height: 140rpx;
            width: 140rpx;
        }
    }

    .mymoney {
        position: relative;
        width: 630rpx;
        height: 220rpx;
        background-color: #fffef4;
        border-radius: 20rpx;
        border: solid 2rpx #f7f5e0;
        margin: 61rpx 60rpx;

        .mymoneyson {
            margin: 53rpx 43rpx;

            .mymon {
                font-family: PingFang-SC-Bold;
                font-size: 28rpx;
                font-weight: normal;
                font-stretch: normal;
                line-height: 29rpx;
                letter-spacing: 0rpx;
                color: #846252;
            }

            .mymonn {
                font-family: PingFang-SC-Heavy;
                font-size: 40rpx;
                font-weight: normal;
                font-stretch: normal;
                line-height: 29rpx;
                letter-spacing: 0rpx;
                color: #ff4200;
                margin-top: 34rpx;

                .text-style-1 {
                    font-family: PingFang-SC-Heavy;
                    font-size: 70rpx;
                    font-weight: normal;
                    letter-spacing: 0rpx;
                    color: #ff4200;
                }
            }

            .sebutton {
                position: absolute;
                top: 75rpx;
                right: 40rpx;
                width: 190rpx;
                height: 70rpx;
                background-image: linear-gradient(90deg,
                        #ffca4b 0%,
                        #ff4200 100%),
                    linear-gradient(#ff5400,
                        #ff5400);
                background-blend-mode: normal,
                    normal;
                box-shadow: 0rpx 15rpx 30rpx 0rpx rgba(255, 68, 1, 0.25);
                border-radius: 35rpx;
                font-family: PingFang-SC-Bold;
                font-size: 28rpx;
                line-height: 70rpx;
                letter-spacing: 0rpx;
                color: #ffffff;
            }

            .sanj {
                position: absolute;
                top: 97rpx;
                right: 40rpx;
                width: 0;
                height: 0;
                border: 14rpx solid #0000FF;
                border-color: transparent transparent transparent #FFFFFF;
            }
        }

    }

    .mysetting {
        width: 630rpx;
        // height: 224rpx;
        background-color: #ffffff;
        box-shadow: 0rpx 0rpx 25rpx 0rpx rgba(0, 0, 0, 0.05);
        border-radius: 20rpx;
        margin: 60rpx 60rpx 140rpx;

        .order {
            display: flex;
            align-items: center;
            margin: 0 30rpx;
            height: 112rpx;

            .orderimg1 {
                width: 56rpx;
                height: 56rpx;
                background-color: #eaf7fa;
                border-radius: 28rpx;
                margin-right: 29rpx;
            }

            span {
                margin-right: 320rpx;
                font-family: PingFang-SC-Bold;
                font-size: 32rpx;
                font-weight: 600;
                color: #191919;
            }

            .orderimg2 {
                width: 30rpx;
                height: 30rpx;
            }
        }



        .Swap {
            display: flex;
            align-items: center;
            margin: 0 33rpx;
            height: 112rpx;
        }

        .Swap .Swapimg1 {
            width: 56rpx;
            height: 56rpx;
            background-color: #fff7f3;
            border-radius: 28rpx;
            margin-right: 29rpx;
        }

        span {
            margin-right: 320rpx;
            font-family: PingFang-SC-Bold;
            font-size: 32rpx;
            font-weight: 600;
            color: #191919;
        }

        .Swap .Swapimg2 {
            width: 30rpx;
            height: 30rpx;
        }
    }
    // 跳转商城 s
    .gotoshop {
        display: flex;
        align-items: center;
        height: 220rpx;
        border-radius: 20rpx;
        background-size: contain;
		margin-left: 50rpx;
		// justify-content: center;
        .img {
            position: absolute;
            width: 628rpx;
            height: 220rpx;
        }
    
        .textbutton {
            z-index: 1;
    
            .text {
                font-size: 36rpx;
                color: #ffffff;
                margin: 48rpx 0 0 68rpx;
                z-index: 12;
            }
    
            .button {
                margin-top: 18rpx;
                width: 251rpx;
    			margin-left: 60rpx;
                height: 60rpx;
                background-color: #faa152;
                border-radius: 30rpx;
    
                font-size: 28rpx;
                color: #ffffff;
                line-height: 60rpx;
            }
        }
    }
    
    // 跳转商城 e
    
    .mymoney,
    .gotoshop,
    .mysetting {
        margin-top: 60rpx;
    }
    .line-space {height: 60rpx;}
</style>
